import logging
from redis import StrictRedis


class MyConfig(object):
    DEBUG = True
    #设置
    """工程配置信息"""
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    #不进行跟踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    #在视图函数结束时候 sqlalchemy 会自动的执行db.session.commit()
    SQLALCHEMY_COMMIT_ON_TEARDOWN =True

    #redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # Session保存配置
    SESSION_TYPE = "redis"
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 指定 Session 保存的 redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    #设置日志的等级
    LOG_LEVEL = logging.WARNING

#开发环境下的配置

#开发环境
class DevelopmentConfig(MyConfig):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG
#生产环境
class ProductionConfig(MyConfig):
    DEBUG = False
    #设置日志的等级
    LOG_LEVEL = logging.WARNING
#测试环境
class TestingConfig(MyConfig):
    DEBUG = True
    TESTING = True

config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}
